package com.enqualcomm.kids.base;

import android.os.Handler;
import android.os.Message;

import java.lang.ref.WeakReference;

/**
 * Created by yinzhiqun on 2015/9/17.
 *
 */
public class MyHandler extends Handler {

    private WeakReference<BaseActivity> weakReference;
    public MyHandler(BaseActivity activity){
        weakReference = new WeakReference<>(activity);
    }

    @Override
    public void handleMessage(Message msg) {
        final BaseActivity activity = weakReference.get();
        if (activity!=null && !activity.isDestroyed){
            activity.handleMessage(msg);
        }
    }

}
